﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace TagPropagator
{
    public class Serializer : ISerializer
    {

        public Graph Deserialize(string file)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Graph));
            using (Stream stream = new FileStream(file, FileMode.Open))
            {
                return (Graph) serializer.Deserialize(stream);
            }
        }

        public void Serialize(Graph graph, string file)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Graph));
            using (Stream stream = new FileStream(file, FileMode.Create))
            {
                serializer.Serialize(stream, graph);
            }
        }
    }
}
